package com.fzhucc.modules.lesson.repository;

import com.fzhucc.modules.lesson.domain.LessonLearnRecord;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
* @website https://eladmin.vip
* @author yyg
* @date 2022-12-08
**/
public interface LessonLearnRecordRepository extends JpaRepository<LessonLearnRecord, Integer>, JpaSpecificationExecutor<LessonLearnRecord> {

    @Query("SELECT a from LessonLearnRecord as a where a.userId=:userId")
    List<LessonLearnRecord> findByUserId(Long userId);

    @Query("SELECT a from LessonLearnRecord as a where a.userId=:userId and a.lessonId=:lesson_id")
    LessonLearnRecord findByUserIdAndLessonId(Long userId, int lesson_id);

    @Query("SELECT a from LessonLearnRecord as a where a.userId=:userId and a.lessonId=:lesson_id")
    List<LessonLearnRecord> findByUserIdAndLessonIdLists(Long userId, int lesson_id);
}